package com.android.picotts.ui.activity.common;

import android.view.View;
import android.view.Window;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;

import com.android.picotts.R;
import com.android.picotts.ui.widget.TitleBar;

/*******************************************************
 * @author : zhaohua
 * @version: 2012-08-14
 * @see:     继承自这个Activity的界面有统一的标题栏
 * @Copyright: copyrights reserved by personal 2007-2012
*******************************************************/
public class TemplateActivity extends BaseActivity
{
	/**标题栏 */
	protected TitleBar mTitleBar;
	/**内容容器*/
	protected LinearLayout mContainer;
	/** 底部栏*/
    protected LinearLayout mBottomBar;
	
	public void setContentView(View view)
	{
		initLayout(view);
	}
	
	@Override
	public void setContentView(int layoutResID)
	{
		View content = getLayoutInflater().inflate(layoutResID, null);
		initLayout(content);
	}
	
	protected void setNoTitle() {
	    getWindow().requestFeature(Window.FEATURE_NO_TITLE);
	}

	private void initLayout(View content) {
		// 设置模板
		super.setContentView(R.layout.activity_template);
		// 初始化模拟成员
		initComponents();		
		// 将内容放入容器		
		mContainer.addView(content,new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
		// 设置模板的标题
		setupTitleBar(mTitleBar);
		// 设置模板的底部栏
        setupBottomBar(mBottomBar);
	}
	
	/**
	 * 初始化三大块：头部的标题栏，中间的内容容器
	 */
	private void initComponents()
	{
	    mTitleBar = (TitleBar)findViewById(R.id.titleBar);	
	    mContainer = (LinearLayout)findViewById(R.id.container);
	    mBottomBar = (LinearLayout)findViewById(R.id.bottomBar);
	}
	
	/** 设置标题栏*/
	protected void setupTitleBar(TitleBar titleBar){}

	/** 设置底部栏*/
    protected void setupBottomBar(LinearLayout bottomBar){}
}